{extend name="index/base" /}
{block name="main"}
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
        <legend>修改栏目</legend>
    </fieldset>
    <form class="layui-form" action="{:url('update')}" method="post">
        <input type="hidden" name="id" value="{$info.id}">
        <div class="layui-form-item">
            <label class="layui-form-label">栏目名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" id="name" value="{$info.name}" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">英文名称</label>
            <div class="layui-input-block">
                <input type="text" name="ename" id="ename" value="{$info.ename}" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属分类</label>
            <div class="layui-input-block">
                <select name="upid" id="upid">
                    <option value="">无上级</option>
                    {:tree_to_select($category_to_tree)}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">栏目title</label>
            <div class="layui-input-block">
                <input type="text" name="title" id="title" value="{$info.title}"  placeholder="seo title 栏目标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">栏目关键字</label>
            <div class="layui-input-block">
                <input type="text" name="keyword" id="keyword" value="{$info.keyword}" placeholder="栏目关键字" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">栏目描述</label>
            <div class="layui-input-block">
                <textarea name="description" id="description" placeholder="栏目描述" class="layui-textarea">{$info.description}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">栏目图片</label>
            <div class="layui-input-block">
                <div class="layui-upload">
                    <button type="button" class="layui-btn" id="test1">上传图片</button>
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="upload_pic" src="{$info.pic}" width="100px">
                        <input type="hidden" name="pic" id="pic" value="">
                        <p id="demoText"></p>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">列表模板</label>
            <div class="layui-input-block">
                <input type="text" name="lists_tpl" id="lists_tpl" value="{$info.lists_tpl}" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">详细模板</label>
            <div class="layui-input-block">
                <input type="text" name="detail_tpl" id="detail_tpl" value="{$info.detail_tpl}" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否显示</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="是" {if condition="$info['status'] eq 1"}checked{/if}>
                <input type="radio" name="status" value="0" title="否" {if condition="$info['status'] eq 0"}checked{/if}>
            </div>
            <div class="layui-form-mid layui-word-aux">关闭时，栏目和前台页面不再显示</div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    {load href="/static/js/jquery-1.10.2.min.js"/}
    <script>
        //Demo
        layui.use('form', function(){
            var form = layui.form;
        });

        //设定分类选择
        $("#upid option").each(function() {
            if($(this).val()=='{$info.upid}'){
                $(this).prop('selected',true);
            }
        });
    </script>



    <script>
        layui.use('upload', function(){
            var upload = layui.upload;
            //执行实例
            var uploadInst = upload.render({
                elem: '#test1' //绑定元素
                ,url: "{:url('File/upload')}" //上传接口
                ,done: function(res){
                    //上传完毕回调
                    layer.msg(res.msg);
                    $('#upload_pic').attr('src',res.data);
                    $('#pic').val(res.data);
                }
                ,error: function(){
                    //请求异常回调
                }
            });
        });
    </script>
{/block}